package com.ymq.reggie.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ymq.reggie.entity.User;
import com.ymq.reggie.mapper.UserMpper;
import com.ymq.reggie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class USerSweviceImpl extends ServiceImpl<UserMpper, User> implements UserService {
    @Autowired
    private JavaMailSender javaMailSender;
    @Value("${spring.mail.username}")
    private String from;
    @Override
    public void sendMsg(String to, String subject, String text) {
        //发送简单邮件，不包含附件
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setFrom(from);
        simpleMailMessage.setTo(to);
        simpleMailMessage.setSubject(subject);
        simpleMailMessage.setText(text);
        //发送邮件
        javaMailSender.send(simpleMailMessage);

    }
}
